#  coding:utf-8
import logging
from logging.handlers import RotatingFileHandler

import redis


# 配置信息
class Config(object):
    DEBUG = True
    SECRET_KEY = '8i8xXnVS7DGr6lHosqrsXbKmn9Z/HcOAJ0+sc4vBXSNVlbs8cpsNJuSV9aM0n6nm'
    # mysql
    # SQLAlCHEMY_DATABASE_URI = 'mysql://root:mysql@127.0.0.1:3306/ihome6'
    SQLALCHEMY_DATABASE_URI = "mysql://root:mysql@127.0.0.1:3306/ihome6"
    # set track
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    # redis host
    REDIS_HOST = '127.0.0.1'
    # redis port
    REDIS_PORT = '6379'
    # flask_session的配置信息
    SESSION_TYPE = "redis"  # 指定 session 保存到 redis 中
    SESSION_USE_SIGNER = True  # 让 cookie 中的 session_id 被加密签名处理
    SESSION_REDIS = redis.StrictRedis(host=REDIS_HOST, port=REDIS_PORT)  # 使用 redis 的实例
    PERMANENT_SESSION_LIFETIME = 86400  # session 的有效期，单位是秒
    # 默认logging的等级为debug
    LOGGING_LEVEL = logging.DEBUG


class DevelopementConfig(Config):
    """开发环境"""
    DEBUG = True


class ProductionConfig(Config):
    """生产环境"""
    SQLALCHEMY_DATABASE_URI = "mysql://root:mysql@127.0.0.1:3306/ihome6"
    # 生产环境时等级为warn
    LOGGING_LEVEL = logging.WARN


config = {
    "development": DevelopementConfig,
    "production": ProductionConfig
}
